package design2;

import java.util.HashMap;

/**
 * Represents cache for various keys and their corresponding values.
 * 
 * @param <K>
 *    The type of the key
 * @param <V>
 *    The type of the value
 */
public class Cache<K, V> {
	
    private HashMap<K, V> keyToValue = new HashMap<>();

	/**
	 * Puts the given key and value into the cache.
	 * 
	 * @param key
	 *    The key to put.
	 * @param value
	 *    The value to put.
	 */
	public void put(K key, V value) {
		keyToValue.put(key, value);
	}
	
	/**
	 * Gets the cache value for the given key.
	 * 
	 * @param key
	 *    The key, for which to get the cache value.
	 * @return
	 *    The cache value for the given key.
	 */
	public V get(K key) {
		return keyToValue.remove(key);
	}

}
